package com.example.a22310.myapplication.Model;


import android.app.Service;

import com.example.a22310.myapplication.Beans.Prize;
import com.example.a22310.myapplication.Listener.ActivityLisenter;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import static com.example.a22310.myapplication.GloableClass.Yuejian.URL;

public class PrizeModel {



    private Retrofit retrofit;
    public PrizeModel()
    {

        retrofit= new Retrofit.Builder()
                .baseUrl(URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }

    public void prizelist(final ActivityLisenter<Prize> lisenter, int suer_id) {
        Service service = retrofit.create(Service.class);
        Call<Prize> call = service.prizelist(suer_id);
        Callback<Prize> callback = new Callback<Prize>() {
            @Override
            public void onResponse(Call<Prize> call, Response<Prize> response) {
                Prize activitys = response.body();

                lisenter.onSuccess(activitys);
            }
            @Override

            public void onFailure(Call<Prize> call, Throwable t) {
                lisenter.onFailure();
            }
        };
        call.enqueue(callback);
    }

}

